<?php
namespace app\index\controller;

use app\model\AdminModel;
use think\facade\Request;
use think\facade\Validate;
use think\facade\View;

class Login{
    //登录
    public function Login_list(){
        return View::fetch();
    }

    //注册
    public function Login_enroll(){
        return View::fetch();
    }
    //
    //验证码
    public function Login_auth(){
        session_start();
        //创建一张图片
        $image = imagecreate(58,25);
        //创建背景为白色
        imagecolorallocate($image,255,255,255);
        $array = [];
        for($i = 1;$i<=4;$i++){
            $str = mt_rand(0,9);//随机的一位数字
            $array[] = $str;
            $font = 4;
            $x = 5 +($i -1)*13;
            $y = 5;
            $color = imagecolorallocate($image,248,181,0);
            imagestring($image,$font,$x,$y,$str,$color);
        }
        $_SESSION['array'] = $array;
        header("Content-type: image/png");
        imagepng($image); // 以 PNG 格式将图像输出到浏览器
        imagedestroy($image); // 销毁一图像， 释放资源
        exit();
    }
    public function play(){
//        stristr( implode($_SESSION['array']),$admin['img'])
        $admin['admin_email'] = '16501893662';
        $useradmin = AdminModel::where('admin_email','=',$admin['admin_email'])->find();
        var_dump($useradmin);
    }

}